<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>函数式组件</title>
  <script src="./js/react.development.js"></script>
  <script src="./js/react-dom.development.js"></script>
  <script src="./js/babel.min.js"></script>
  <style>
    header {
      height: 100px;
      background-color: #aef;
    }

    main {
      height: 350px;
      background-color: #ceb;
    }

    footer {
      height: 100px;
      background-color: #fea;
    }
  </style>
</head>

<body>
  <div id="root"></div>
  <script type="text/babel">
    //声明一个函数组件
    function Header() {
      return <header>头部结构</header>;
    }

    function Main() {
      return <main></main>;
    }

    function Footer() {
      return <footer></footer>
    }

    //渲染
    ReactDOM.render(<App />, document.querySelector('#root'));

    //自定义渲染函数式组件
    function render(vnode, parent){
      //调用 vnode.type 函数
      let vdom = vnode.type();
      //创建元素
      let el = document.createElement(vdom.type);
      //设置 el 的标签文本
      el.innerHTML = vdom.props.children;
      //插入
      parent.append(el);
    }
    let vheader = <Header></Header>;

    render(vheader, document.querySelector('#root'));
  </script>
</body>

</html>